//index.js
//获取应用实例
const app = getApp();
const common = require('../common/common.js');
let pood,types='',ids;
Page({
  data: {
    hidden: false,
    boolT: true,
    alist: []
  },
  onLoad: function (options) {
    let that = this;
    types=options.page;
    ids=options.id;
    pood = wx.getStorageSync('pood') || '';
    that.setData({
      alist: pood.zitiAddressList
    })
    console.log(that.data.alist)
  },
  sdefult:function(e){
    let that = this;
    let id = e.currentTarget.dataset.id;
    if (that.data.boolT){
      that.data.boolT=false;
      let newArr = [];
      for (let i = 0; i < that.data.alist.length; i++) {
        if (that.data.alist[i].id != id) {
          newArr.push(that.data.alist[i])
        } else {
          newArr.unshift(that.data.alist[i])
        }
      }
      that.data.alist = newArr;
      pood.zitiAddressList = that.data.alist;
      wx.setStorageSync('pood', pood);
      let pageUrl = '';
      if (types == '1') {
        pageUrl = '../paired_order/paired_order?id=' + ids
      } else if (types == '2') {
        pageUrl = '../confirm_order/confirm_order?id=' + ids
      }
      wx.redirectTo({
        url: pageUrl,
        success: function () {
          setTimeout(function () {
            that.data.boolT = true;
          }, 500)
        }
      })
    }
  }
})
